<script lang="ts" setup>
import { FFSchema } from '@fate/components/fate-form/fform.types';

import { useDialog } from '@fate/components/fate-dialog/useDialog.ts';
import FForm from '@fate/components/fate-form/FForm.vue';

const schema: FFSchema = {
  properties: {
    name: {
      title: '姓名',
      type: 'string',
      layout: {
        span: 24
      },
      tips: () => {
        return h('div', '我是提示');
      }
    }
  },
  elementWidth: 200,
  required: ['name']
};

function submit() {
  const dialog = useDialog();
  const { result, close } = dialog({
    title: '早',
    props: {
      msg: '1111'
    }
  });

  // 外部调用关闭弹窗并传递参数
  setTimeout(() => {
    close();
  }, 5000);

  // 处理关闭时的返回值
  result.then((result) => {
    console.log('弹窗关闭，参数：', result);
  });
}
</script>

<template>
  <FForm
    :schema="schema"
    :model="{
      sex: 1,
      name: '222'
    }"
  />
  <el-button @click="submit">提交</el-button>
</template>

<style scoped></style>
